﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 
using System.Windows.Forms; 
using System.ComponentModel;
using System.Drawing;
using Stone.DataContracts;

namespace CourseArraging.Frm.jcxx
{
    /// <summary>
    /// 版权所有
    /// 石世特@温州医学院 sst330381@gmail.com
    /// </summary> 
    public class FrmInfoSchool : FrmToolbarBase
    {
        // Fields
        protected BasicService.BasicServiceClient basicdao = new BasicService.BasicServiceClient();
        private IContainer components = null;
        private GroupBox groupBox1;
        protected Label label_id;
        private Label label1;
        private Label label2;
        private Label label23;
        private Label label3;
        private RichTextBox txt_address;
        protected TextBox txt_content;
        protected TextBox txt_dh;

        // Events
        public event refreshlist reflist;

        // Methods
        public FrmInfoSchool(DepEntity de)
        {
            this.InitializeComponent();
            this.Text = "分校信息";
            this.label_id.Text = de.dep_info_id.ToString();
            this.txt_content.Text = de.dep_info_name;
            this.txt_dh.Text = de.dep_info_phone;
            this.txt_address.Text = de.dep_info_address;
            base.tsb_delete.Visible = false;
            base.tsb_print.Visible = false;
            base.tsb_refresh.Visible = false;
            base.tsb_print.Visible = false;
            base.tsb_search.Visible = false;
        }

        public override bool be4save()
        {
            return true;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txt_dh = new System.Windows.Forms.TextBox();
            this.txt_address = new System.Windows.Forms.RichTextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.label_id = new System.Windows.Forms.Label();
            this.label23 = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.txt_content = new System.Windows.Forms.TextBox();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.txt_dh);
            this.groupBox1.Controls.Add(this.txt_address);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.label_id);
            this.groupBox1.Controls.Add(this.label23);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.txt_content);
            this.groupBox1.Location = new System.Drawing.Point(23, 50);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(307, 244);
            this.groupBox1.TabIndex = 99;
            this.groupBox1.TabStop = false;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font("微软雅黑", 10F);
            this.label3.ForeColor = System.Drawing.Color.Black;
            this.label3.Location = new System.Drawing.Point(31, 113);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(48, 20);
            this.label3.TabIndex = 102;
            this.label3.Text = "电 话 :";
            // 
            // txt_dh
            // 
            this.txt_dh.BackColor = System.Drawing.SystemColors.Window;
            this.txt_dh.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txt_dh.Location = new System.Drawing.Point(85, 111);
            this.txt_dh.Name = "txt_dh";
            this.txt_dh.Size = new System.Drawing.Size(200, 25);
            this.txt_dh.TabIndex = 101;
            // 
            // txt_address
            // 
            this.txt_address.Font = new System.Drawing.Font("微软雅黑", 9.75F);
            this.txt_address.Location = new System.Drawing.Point(85, 155);
            this.txt_address.Name = "txt_address";
            this.txt_address.Size = new System.Drawing.Size(200, 71);
            this.txt_address.TabIndex = 100;
            this.txt_address.Text = "";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font("微软雅黑", 10F);
            this.label2.ForeColor = System.Drawing.Color.Black;
            this.label2.Location = new System.Drawing.Point(31, 155);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(48, 20);
            this.label2.TabIndex = 99;
            this.label2.Text = "地 址 :";
            // 
            // label_id
            // 
            this.label_id.AutoSize = true;
            this.label_id.Font = new System.Drawing.Font("微软雅黑", 10F);
            this.label_id.ForeColor = System.Drawing.Color.Black;
            this.label_id.Location = new System.Drawing.Point(109, 31);
            this.label_id.Name = "label_id";
            this.label_id.Size = new System.Drawing.Size(48, 20);
            this.label_id.TabIndex = 97;
            this.label_id.Text = "编 号 :";
            // 
            // label23
            // 
            this.label23.AutoSize = true;
            this.label23.Font = new System.Drawing.Font("微软雅黑", 10F);
            this.label23.ForeColor = System.Drawing.Color.Black;
            this.label23.Location = new System.Drawing.Point(31, 31);
            this.label23.Name = "label23";
            this.label23.Size = new System.Drawing.Size(48, 20);
            this.label23.TabIndex = 94;
            this.label23.Text = "编 号 :";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font("微软雅黑", 10F);
            this.label1.ForeColor = System.Drawing.Color.Black;
            this.label1.Location = new System.Drawing.Point(31, 71);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(48, 20);
            this.label1.TabIndex = 96;
            this.label1.Text = "名 称 :";
            // 
            // txt_content
            // 
            this.txt_content.BackColor = System.Drawing.SystemColors.Window;
            this.txt_content.Font = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.txt_content.Location = new System.Drawing.Point(85, 69);
            this.txt_content.Name = "txt_content";
            this.txt_content.Size = new System.Drawing.Size(200, 25);
            this.txt_content.TabIndex = 95;
            // 
            // FrmInfoSchool
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.ClientSize = new System.Drawing.Size(351, 306);
            this.Controls.Add(this.groupBox1);
            this.Name = "FrmInfoSchool";
            this.Text = "FrmInfoSchool";
            this.Controls.SetChildIndex(this.groupBox1, 0);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        public override void tsb_new_fun()
        {
            this.label_id.Text = string.Empty;
            this.txt_content.Text = string.Empty;
            this.txt_address.Text = string.Empty;
        }

        public override void tsb_save_fun()
        {
            if (string.IsNullOrEmpty(this.label_id.Text))
            {
                if (this.basicdao.getEqualDep(this.txt_content.Text.Trim()))
                {
                    MessageBox.Show("已经存在该项, 请重新填写 ! ");
                    return;
                }
                DepEntity dep = new DepEntity();
                dep.dep_info_name = this.txt_content.Text;
                dep.dep_info_phone = this.txt_dh.Text;
                dep.dep_info_address = this.txt_address.Text;
                this.basicdao.addDepInfo(dep);
                MessageBox.Show("添加成功 !");
            }
            else
            {
                DepEntity entity2 = new DepEntity();
                entity2.dep_info_id = int.Parse(this.label_id.Text);
                entity2.dep_info_name = this.txt_content.Text;
                entity2.dep_info_phone = this.txt_dh.Text;
                entity2.dep_info_address = this.txt_address.Text;
                this.basicdao.updateDepinfo(entity2);
                MessageBox.Show("修改成功 !");
            }
            base.Close();
            this.reflist();
        }

        public override void tsb_del_fun()
        {
            
        }

        // Nested Types
        public delegate void refreshlist();
    }

 

}
